﻿<%@ WebHandler Language="C#" Class="img_get" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Collections.Generic;
using System.Web.SessionState;

public class img_get : IHttpHandler, IRequiresSessionState
{
    sqlhelp sql = new sqlhelp();
    imgResult result = new imgResult();
    public List<img> imgList = new List<img>();
    System.Data.DataTable dt = new System.Data.DataTable(); 
    string str = "";
    public void ProcessRequest (HttpContext context) {
        try
        {
            if (context.Session["comid"] == null)
            {
                result.code = "-1";
                result.msg = "用户未登录";
                unit.send(context, result);
                return;
            }
            string Linkid = "";
            if (context.Request["Linkid"] != null)
            {
                Linkid = context.Request["Linkid"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递官网BannerId参数";
                unit.send(context, result);
                return;
            }
            str = "select * from SYS_Image where Enable = 1 and  Linkid = '" + Linkid + "'";
            dt = sql.myDataSet(str ).Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++) {
                img _img = new img();
                _img.Id = dt.Rows[i]["Id"].ToString();
                _img.Linkid = dt.Rows[i]["Linkid"].ToString();
                _img.Path = dt.Rows[i]["Path"].ToString();
                _img.CreateTime = dt.Rows[i]["CreateTime"].ToString();
                _img.Enable = dt.Rows[i]["Enable"].ToString();
                imgList.Add(_img);
            }
            result.data = imgList;

        }
        catch (Exception e1)
        {
            result.code = "0";
            result.msg = e1.Message;
        }
        unit.send(context, result);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

public class imgResult : result {
    public List<img> data = new List<img>();
}

public class img { 
    public string Id = "";//	uniqueidentifier	0	id
    public string Linkid = "";//	uniqueidentifier	0	关联id
    public string Path = "";//	nvarchar(200)	0	图片路径
    public string CreateTime = "";//	nvarchar(20)	0	录入时间
    public string Enable = "";//	int	0	是否有效

}